﻿using Demo.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Thrift.Server;
using Thrift.Transport;

namespace Demo.Server
{
    class Program
    {
        static void Main(string[] args)
        {
            var engine = new BPMEngineImpl();
            var processor = new BPMEngine.Processor(engine);
            var transport = new TServerSocket(8800);
            var _server = new TThreadPoolServer(processor, transport);
            Console.WriteLine($"[{DateTime.Now}]ThriftServer running.");
            _server.Serve();

            Console.ReadLine();
        }
    }

    public class BPMEngineImpl : BPMEngine.Iface
    {
        public List<string> GetDestination(int procInstId, string activityName)
        {
            Console.WriteLine($"GetDestination#{activityName}");
            return new List<string>();
        }

        public void Log(string logInfo)
        {
            Console.WriteLine($"Log#{logInfo}");
        }

        public void OnApprovalCompleted(int procInstId)
        {
            Console.WriteLine($"OnApprovalCompleted#{procInstId}");
        }

        public void OnEmailNotify(int procInstId, string destination, string sn)
        {
            Console.WriteLine($"OnEmailNotify");
        }

        public void OnInitializationCompleted(int procInstId, string folio)
        {
            Console.WriteLine($"OnInitializationCompleted#{procInstId}");
        }

        public void OnRejected(string currentDestination, int procInstId, string activityName)
        {
            Console.WriteLine($"OnRejected#{activityName}");
        }
    }
}
